<?php
namespace library\Core\Comm;

class Session {

    public static $_SESSION_START = false;

    public static function start() {

        self::$_SESSION_START = session_start();
        return self::$_SESSION_START;
    }

    public static function cache_limiter($cache_limiter = null) {
        return session_cache_limiter($cache_limiter);
    }

    public static function get($name) {
        if (!self::$_SESSION_START)
            throw new Core_Exception_Session('session_start() must be called');
        return isset($_SESSION[$name]) ? $_SESSION[$name] : null;
    }

    public static function set($name, $val) {
        if (!self::$_SESSION_START)
            throw new Core_Exception_Session('session_start() must be called');
        return $_SESSION[$name] = $val;
    }

    public static function remove($name) {
        unset($_SESSION[$name]);
    }

    public static function freesAll() {
        session_unset();
    }

}
